package app.cn.com.school.activity

import android.os.Bundle
import app.cn.com.school.R
import app.cn.com.school.adapter.MyViewPagerAdapter
import app.cn.com.school.databinding.ActivityStoreDetailsBinding
import app.cn.com.school.fragment.BaseVlayoutFragment
import com.cndll.upclass.ui.frag.BlankFragment

class StoreDetailsActivity : BaseActivity<ActivityStoreDetailsBinding>() {
    override fun initBindingVar() {
    }

    override fun initTitle() {
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initBinding(R.layout.activity_store_details)
        initData()
    }

    private var type = 0
    private var arr = arrayOf<Array<String>>(arrayOf("全部商品", "销量排序", "上新"), arrayOf("商品", "店铺详情"))
    private var fragmentList = ArrayList<BaseVlayoutFragment>()
    private var adapter: MyViewPagerAdapter? = null

    private fun initData() {
        var extras = this.intent.extras
        if (extras != null && extras.containsKey("type")) {
            type = extras.getInt("type", 0)
        }

        when (type) {
            0 -> {
                fragmentList.add(BlankFragment.newInstance())
                fragmentList.add(BlankFragment.newInstance())
                fragmentList.add(BlankFragment.newInstance())
            }
            1 -> {
                fragmentList.add(BlankFragment.newInstance())
                fragmentList.add(BlankFragment.newInstance())
            }
        }

        adapter = MyViewPagerAdapter(supportFragmentManager, fragmentList, arr[type])
        binding.favViewpager.adapter = adapter
        binding.favTab.setupWithViewPager(binding.favViewpager)
        binding.favTab.setTabsFromPagerAdapter(adapter)
    }
}
